package com.bamatea.reportfrom.service;

import com.bamatea.reportfrom.dao.PoOrderBWcMapper;
import com.bamatea.reportfrom.domain.*;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * @Auther: libingbing
 * @Date: 2020-04-26 10 :37
 * @Description: 采购数据主表
 */
@Service
public class poOrderBwcService {
    @Resource
    private PoOrderBWcMapper mapper;

    public PoOrderBWc findBySku(String invcode) {
        PoOrderBWcExample example = new PoOrderBWcExample();
        example.or().andInvcodeEqualTo(invcode);
        return mapper.selectOneByExampleSelective(example, PoOrderBWc.Column.norgtaxprice);
    }

    public List<PoOrderBWc> findAll() {
        PoOrderBWcExample example = new PoOrderBWcExample();
        PageHelper.startPage(1, 200);
        return mapper.selectByExample(example);
    }

    public List<PoOrderBWc> findByStartAndEnds(String start, String end) {
        PoOrderBWcExample example = new PoOrderBWcExample();
//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//        String start1 = formatter.format(start);
//        String end1 = formatter.format(end);
        example.or().andDorderdateBetween(start, end);
        return mapper.selectByExample(example);
    }

    public List<PoOrderBWc> findByCatIds(String invclasscode) {
        PoOrderBWcExample example = new PoOrderBWcExample();
        example.or().andInvclasscodeEqualTo(invclasscode);
        return mapper.selectByExample(example);

    }

        public List<PoOrderBWc> findAlls () {
            PoOrderBWcExample examples = new PoOrderBWcExample();
            //examples.setDistinct(true);
            return mapper.selectByExampleSelective(examples, PoOrderBWc.Column.dauditdate);
        }


    public List<PoOrderBWc> findBycode(List<String> code){
        PoOrderBWcExample example = new PoOrderBWcExample();
        example.or().andInvclasscodeIn(code);
        return mapper.selectByExample(example);
    }

}
